﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace ebc.componentbinder.tests
{
    [TestFixture]
    public class test_CompileEventhandlersDefinedByType
    {
        [Test]
        public void Finds_relevant_eventhandlers()
        {
            var ehdList = ComponentBinder.CompileEventHandlersPublishedBy(new SomeRelevantEventhandlers());
            Assert.AreEqual(1, ehdList.Count());
            Assert.AreEqual("String", ehdList.First().PinName);
        }            


        [Test]
        public void Finds_eventhandlers_in_base_class()
        {
            var ehdList = ComponentBinder.CompileEventHandlersPublishedBy(new DerivedEventhandlerClass());
            Assert.That(ehdList.Select(eh => eh.PinName).ToArray(),
                        Is.EquivalentTo(new[]{"String", "Int"}));
        }
    }
}
